package com.example.pfe_copie_finale;

import android.app.Activity;
import android.os.Bundle;
import java.util.Calendar;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.view.View;
import android.widget.DatePicker;
import android.widget.EditText;
import com.example.pfe_copie_finale.R;

public class BonEntre extends Activity{
	private EditText pickDate;
	private int mYear;
	private int mMonth;
	private int mDay;
	static final int DATE_DIALOG_ID = 1;
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_b_entre);
		pickDate = (EditText) findViewById(R.id.date);
		pickDate.setOnClickListener(new View.OnClickListener() {

		public void onClick(View v) {
		showDialog(DATE_DIALOG_ID);
		}
		});
		final Calendar c = Calendar.getInstance();
		mYear = c.get(Calendar.YEAR);
		mMonth = c.get(Calendar.MONTH);
		mDay = c.get(Calendar.DAY_OF_MONTH);
		updateDisplay();
		

}
	protected Dialog onCreateDialog(int id) {
		switch (id) {

		case DATE_DIALOG_ID:
		return new DatePickerDialog(this,
		mDateSetListener,
		mYear, mMonth, mDay);
		}
		return null;
		}
		protected void onPrepareDialog(int id, Dialog dialog) {
		switch (id) {

		case DATE_DIALOG_ID:
		((DatePickerDialog) dialog).updateDate(mYear, mMonth, mDay);
		break;
		}
		}
		private void updateDisplay() {
		pickDate.setText(
		new StringBuilder()
		// Month is 0 based so add 1
		.append(mDay ).append("-")
		.append(mMonth+1).append("-")
		.append(mYear).append(" "));
		}
		private DatePickerDialog.OnDateSetListener mDateSetListener =
		new DatePickerDialog.OnDateSetListener() {

		public void onDateSet(DatePicker view, int year, int monthOfYear,
		int dayOfMonth) {
		mYear = year;
		mMonth = monthOfYear;
		mDay = dayOfMonth;
		updateDisplay();
		}
		};
}